package com.bilibili.juc.me;

import lombok.extern.slf4j.Slf4j;
/*
测试不用第三个数据交换两个数
 */
@Slf4j(topic = "c.ChangeValueDemo")
public class ChangeValueDemo {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        log.debug("exchange before a:{},b:{}",a,b);
        b = a|b;
        a=b^a;
        b=b^a;
        log.debug("exchange after a:{},b:{}",a,b);
        log.debug("===========================");

        int m = 10;
        int n = 20;
        log.debug("exchange before m:{},n:{}",m,n);
        m = m+n;
        n=m-n;
        m=m-n;
        log.debug("exchange after m:{},n:{}",m,n);
    }
}
